//package com.sky.security;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.builders.WebSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.config.http.SessionCreationPolicy;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
//import springfox.documentation.builders.ApiInfoBuilder;
//import springfox.documentation.builders.PathSelectors;
//import springfox.documentation.builders.RequestHandlerSelectors;
//import springfox.documentation.service.ApiInfo;
//import springfox.documentation.spi.DocumentationType;
//import springfox.documentation.spring.web.plugins.Docket;
//
//@Configuration
//@EnableWebSecurity
//public class securityConfig extends WebSecurityConfigurerAdapter {
//    private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
//    //private MyJwtAuthenticationTokenFilter myJwtAuthenticationTokenFilter;
//    @Autowired
//    private PasswordEncoder passwordEncoder;
////    @Autowired
////    @Qualifier("employeeServiceImpl")
////    private UserDetailsService EuserDetailsService;
//
//    @Autowired
//    //@Qualifier("sysUserServiceImpl")
//    private UserDetailsService userDetailsService;
//    public securityConfig(JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter) {
//        this.jwtAuthenticationTokenFilter = jwtAuthenticationTokenFilter;
//    }
//
//    @Override
//    protected void configure(HttpSecurity http) throws Exception {
//        http
//                //异常处理
//                .exceptionHandling()
//                //传入自定义异常处理MyAuthenticationEntryPoint()
//                .authenticationEntryPoint(new MyAuthenticationEntryPoint()).and()
//                //关闭csrf攻击防御
//                .csrf().disable()
//                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
//                .authorizeRequests()
//                .antMatchers("/admin/employee/login",
//                             "/admin/employee/add",
//                             "/user/user/login",
//                        "/sms/sendMsg",
//                        "/sys/login",
//                        "/sys/loginByPhone",
//                        "/sys/register",
//                        "/sys/getVerifyCode").permitAll()
//                //拦截所有请求
//                .anyRequest().authenticated()
//                .and()
//                .formLogin().loginProcessingUrl("/admin/employee/login/").permitAll()
//                .and()
//                .logout().logoutUrl("/admin/employee/logout").permitAll()
//                .and().cors()
//                //在执行用户认证后进行过滤
//                .and().addFilterAfter(jwtAuthenticationTokenFilter,
//                        UsernamePasswordAuthenticationFilter.class);
//
//
//    }
//
//    @Override
//    public void configure(WebSecurity web) {
//        web.ignoring().antMatchers("/doc.html",
//                "/webjars/**",
//                "/swagger-resources/**",
//                "/v2/api-docs");
//
//    }
//    @Override
//    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
////        auth.userDetailsService(EuserDetailsService)
////                .passwordEncoder(passwordEncoder);
//        auth.userDetailsService(userDetailsService)
//                .passwordEncoder(passwordEncoder);
//    }
//    @Bean
//    public AuthenticationManager authenticationManagerBean(AuthenticationConfiguration config) throws Exception {
//        return config.getAuthenticationManager();
//    }
//}
